home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 8 / 008.d81 / pps #19 < prev    next >
Text File  |  2022-08-26  |  2KB  |  155 lines

  1.  
  2.  PEEKs, POKEs, and SYSes -- Part 19
  3.  
  4.  
  5.           by Jimmy Weiler
  6.  
  7.  
  8.  
  9.  
  10.  
  11.   We still need to tell VIC what color
  12.  
  13. to make our sprite.  Memory locations
  14.  
  15. V+39 to V+46 are for sprite color.
  16.  
  17. Use the same color values you normally
  18.  
  19. use in basic -- 0 = black; 1 = white;
  20.  
  21. etc.
  22.  
  23.  
  24. 190 POKE V+39,7
  25.  
  26.  
  27. This will make our umbrella sprite
  28.  
  29. yellow.
  30.  
  31.  
  32.   What about size?  We have four
  33.  
  34. options.  We can expand it vertically,
  35.  
  36. or horizontally, or both, or neither.
  37.  
  38. To expand it vertically, set the
  39.  
  40. corresponding bit in V+23.  To expand
  41.  
  42. horizontally, use V+29.  Let's expand
  43.  
  44. our umbrella in both directions.
  45.  
  46.  
  47. 200 POKE V+23,PEEK(V+23) OR 1
  48. 210 POKE V+29,PEEK(V+29) OR 1
  49.  
  50.  
  51. The OR 1 in these statements makes
  52.  
  53. sure that we change only the value of
  54.  
  55. bit one of bytes V+23 and V+29.  We
  56.  
  57. wouldn't want to unexpectedly expand
  58.  
  59. one of the other sprites.
  60.  
  61.  
  62.   To make your sprite go behind text
  63.  
  64. on the screen, put a 1 in the
  65.  
  66. corresponding bit of V+27.  A 0 will
  67.  
  68. make your sprite cover the text.
  69.  
  70.  
  71. 220 POKE V+27,PEEK(V+27) AND 254
  72.  
  73.  
  74.   Now we're almost done.  All we have
  75.  
  76. to do is make the sprite visible.
  77.  
  78. V+21 is the location for that.  As
  79.  
  80. usual, each bit of byte V+21
  81.  
  82. corresponds to the sprite of the same
  83.  
  84. number.
  85.  
  86.  
  87. 230 POKE V+21,PEEK(V+21) OR 1
  88.  
  89.  
  90.   At last we're ready for some
  91.  
  92. animation.  Let's keep it simple.
  93.  
  94. We'll just let the umbrella drop from
  95.  
  96. the top of the screen to the bottom.
  97.  
  98.  
  99. 300 FOR VP = 50 TO 230 STEP .2
  100. 310 POKE V+1,VP
  101. 320 NEXT
  102.  
  103.  
  104.   Well, that works fine, but it's not
  105.  
  106. much fun.  Let's see if we can spice
  107.  
  108. it up a little.
  109.  
  110.  
  111.   First, add a sprite image of a
  112.  
  113. closed umbrella:
  114.  
  115.  
  116. 111 DATA 0,24,0,0,24,0,0,24,0,0,60,0,
  117. 0,60,0,0,60,0,0,126,0,0,126,0
  118. 112 DATA 0,126,0,0,255,0,0,24,0,0,24,
  119. 0,0,24,0,0,24,128,0,14,0,0,0,0,0,0,0,0
  120. 113 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0
  121. 114 FOR BL = 896 TO 896 + 62
  122. 115 READ D
  123. 116 POKE BL,D
  124. 117 NEXT BL
  125.  
  126.  
  127.   This code will POKE the image into
  128.  
  129. sprite page 14.  Next we add code to
  130.  
  131. make the closed umbrella jump back up
  132.  
  133. to the top of the screen.
  134.  
  135.  
  136. 325 POKE 2040,14:rem sprite 1 = pg 14
  137. 330 FOR VP = 230 TO 50 STEP -2
  138. 340 POKE V+1,VP
  139. 350 NEXT
  140. 370 GOTO 120
  141.  
  142.  
  143.   Not bad.... with a little work
  144.  
  145. someone could make a game out of this.
  146.  
  147.  
  148. >For those of you who don't like to
  149.  type that much, this entire program
  150.  is on SIDE 2 of LOADSTAR 8.  It is
  151.  saved under the name UMBRELLA DEMO.
  152.  
  153.  
  154. ---------- End of Article ------------
  155.